package com.googlecode.gwtbb.client.shared.remote.forum;

import com.googlecode.gwtbb.client.shared.entity.forum.Forum;
import com.googlecode.gwtbb.client.shared.validation.Failure;
import com.googlecode.gwtbb.client.shared.validation.FieldId;
import com.googlecode.gwtbb.client.shared.validation.GwtbbValidator;
import com.googlecode.gwtbb.client.shared.validation.Validateable;

import java.io.Serializable;
import java.util.Map;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Apr 30, 2008
 */
public class CreateForumBean implements Validateable, Serializable {
	private String name;
	private String description;
	private boolean listed = true;

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isListed() {
		return listed;
	}

	public void setListed(boolean listed) {
		this.listed = listed;
	}

	public Map<FieldId, Failure> validate(Map<FieldId, Failure> failures, int index) {
		name = GwtbbValidator.minMax(failures, FieldId.create(Forum.NAME, index), name, Forum.NAME_MIN, Forum.NAME_MAX);
		description = GwtbbValidator.max(failures, FieldId.create(Forum.DESCRIPTION, index), description, Forum.DESCRIPTION_MAX);
		return failures;
	}
}
